# Contributor: rubicon <rubicon@mailo.com>
# Maintainer:
pkgname=chamo
pkgver=3.0
pkgrel=1
pkgdesc="Emacs-inspired text editor written in and configurable with OCaml"
url="https://zoggy.frama.io/chamo"
arch="all !riscv64"  # limited by ocaml aport
license="LGPL-3.0-only"
# lablgtk3-sourceview3 is bundled together in ocaml-lablgtk3
depends_dev="
	ocaml-lablgtk3-dev
	ocaml-lablgtk3-extras-dev
	ocaml-logs-dev
	ocaml-lwt-dev
	ocaml-lwt_ppx-dev
	ocaml-ocf-dev
	ocaml-pcre-dev
	ocaml-sedlex-dev
	ocaml-uutf-dev
	ocaml-xmlm-dev
	"
makedepends="
	$depends_dev
	gnu-libiconv
	ocaml
	ocaml-compiler-libs
	ocaml-findlib
	ocaml-ocamldoc
	"
options="!check"
subpackages="$pkgname-dev"
source="$pkgname-$pkgver.tar.bz2::https://framagit.org/zoggy/chamo/-/archive/$pkgver/chamo-$pkgver.tar.bz2"
_ocamldir=usr/lib/ocaml

# 32-bit archs
case "$CARCH" in
	arm*|x86) options="$options textrels" ;;
esac

build() {
	export ICONV=/usr/bin/gnu-iconv
	./configure --prefix /usr
	make -j1 all
}

package() {
	export OCAMLFIND_DESTDIR="$pkgdir/$_ocamldir"
	export OCAMLFIND_LDCONF=ignore
	mkdir -vp "$OCAMLFIND_DESTDIR"

	local pkgdirshare="$pkgdir"/usr/share/chamo3
	make	GLADEDIR="$pkgdirshare"/glade \
		PIXMAPSDIR="$pkgdirshare"/pixmaps install

	local chamobinary="$OCAMLFIND_DESTDIR"/chamo3/chamo
	install -Dv $chamobinary -t "$pkgdir"/usr/bin/
	rm -v $chamobinary
}

dev() {
	depends="$depends_dev ocaml-runtime"
	pkgdesc="$pkgdesc (development files)"

	amove $_ocamldir
}

sha512sums="
f5d2980bf67c5e8b98dd8e0d8eaa7fdf96c762c2bc5907d7eba3737978d27dfff76a37cea29d1470a78b77aa0114655a65c723d4eeebad8198d23703294d724d  chamo-3.0.tar.bz2
"
